# 登录解析 https://www.fenbi.com/page/home
import requests
import execjs

cookies = {
    'sajssdk_2015_cross_new_user': '1',
    'sensorsdata2015jssdkcross': '%7B%22distinct_id%22%3A%2218bf9e6d25f1153-0b6816c75e34f1-26031051-2073600-18bf9e6d2607ec%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fgithub.com%2Fliyf-code%2Freverse_practice%22%7D%2C%22%24device_id%22%3A%2218bf9e6d25f1153-0b6816c75e34f1-26031051-2073600-18bf9e6d2607ec%22%7D',
    'acw_tc': '0a099dd617007047359603828e314abc374b7d391d5038df06b877135dc891',
}

headers = {
    'authority': 'login.fenbi.com',
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
    # 'cookie': 'sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2218bf9e6d25f1153-0b6816c75e34f1-26031051-2073600-18bf9e6d2607ec%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fgithub.com%2Fliyf-code%2Freverse_practice%22%7D%2C%22%24device_id%22%3A%2218bf9e6d25f1153-0b6816c75e34f1-26031051-2073600-18bf9e6d2607ec%22%7D; acw_tc=0a099dd617007047359603828e314abc374b7d391d5038df06b877135dc891',
    'origin': 'https://fenbi.com',
    'pragma': 'no-cache',
    'referer': 'https://fenbi.com/',
    'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
}

params = {
    'kav': '100',
    'app': 'web',
    'av': '100',
    'hav': '100',
    'client_context_id': '9f39ad60afff26e838d1a89dfa8bc403',
}
password = execjs.compile(open('逆向JS.js','r',encoding='utf-8').read()).call("enctypt_data","123456")


data = {
    'password': password,
    'persistent': 'true',
    'app': 'web',
    'phone': '18692739419',
}

response = requests.post('https://login.fenbi.com/api/users/loginV2', params=params, cookies=cookies, headers=headers, data=data)

print(response.text)
